﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:Controls="clr-namespace:WindowsPhoneEssentials.Controls" mc:Ignorable="d">

    <DataTemplate x:Key="LoadingTextDataTemplate">
        <TextBlock HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   TextWrapping="Wrap"
                   Style="{StaticResource PhoneTextLargeStyle}"
                   Text="{Binding}" />
    </DataTemplate>

    <DataTemplate x:Key="LoadingTextSmallDataTemplate">
        <TextBlock HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   TextWrapping="Wrap"
                   Style="{StaticResource PhoneTextNormalStyle}"
                   Text="{Binding}" />
    </DataTemplate>

    <Style TargetType="Controls:LoadingPivotItem">
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="Margin"
                Value="12,28,12,0" />
        <Setter Property="Padding"
                Value="0" />
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <Setter Property="VerticalContentAlignment"
                Value="Stretch" />
        <Setter Property="LoadingText"
                Value="Loading..." />
        <Setter Property="Timeout"
                Value="0:0:15" />
        <Setter Property="FailureText"
                Value="The information could not be loaded. Please check your data connection or try again later." />
        <Setter Property="RetryText"
                Value="The information could not be loaded. Please check your data connection or try again now." />
        <Setter Property="TimeoutText"
                Value="It's taking a long time to gather the information. Please check your data connection." />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:LoadingPivotItem">
                    <Controls:LoadingContentControl LoadImmediately="False"
                                                    x:Name="Content"
                                                    HorizontalAlignment="Stretch"
                                                    VerticalAlignment="Stretch"
                                                    HorizontalContentAlignment="Stretch"
                                                    VerticalContentAlignment="Stretch"
                                                    CoverOffset="{TemplateBinding LoadingMargin}"
                                                    LoadingContent="{TemplateBinding LoadingText}"
                                                    FailureContent="{TemplateBinding FailureText}"
                                                    RetryContent="{TemplateBinding RetryText}"
                                                    TimeoutContent="{TemplateBinding TimeoutText}"
                                                    Timeout="{TemplateBinding Timeout}"
                                                    Content="{TemplateBinding Content}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Controls:CoverContentControl">
        <Setter Property="Background"
                Value="{StaticResource PhoneBackgroundBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:CoverContentControl">
                    <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="Covering">
                                <VisualState x:Name="Covered">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="Cover">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation BeginTime="0"
                                                         Duration="0:0:0.5"
                                                         To="1"
                                                         Storyboard.TargetName="Cover"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Uncovered">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="Cover">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.5">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation BeginTime="0"
                                                         Duration="0:0:0.5"
                                                         To="0"
                                                         Storyboard.TargetName="Cover"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid CacheMode="BitmapCache"
                              Visibility="Collapsed"
                              x:Name="Content" />
                        <Grid x:Name="Cover"
                              Background="{TemplateBinding Background}"
                              Margin="{TemplateBinding CoverOffset}">
                            <ContentPresenter Content="{TemplateBinding Cover}"
                                              ContentTemplate="{TemplateBinding CoverTemplate}" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Controls:LoadingContentControl">
        <Setter Property="Background"
                Value="{StaticResource PhoneBackgroundBrush}" />
        <Setter Property="ReleaseContentTree"
                Value="False" />
        <Setter Property="LoadingDisplayOffset"
                Value="0:0:0.10" />
        <Setter Property="LoadingContent"
                Value="Loading..." />
        <Setter Property="LoadingContentTemplate"
                Value="{StaticResource LoadingTextDataTemplate}" />
        <Setter Property="FailureContent"
                Value="Failure!" />
        <Setter Property="FailureContentTemplate"
                Value="{StaticResource LoadingTextDataTemplate}" />
        <Setter Property="RetryContent"
                Value="The information could not be loaded. Please check the data connection or try again later." />
        <Setter Property="RetryContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock HorizontalAlignment="Left"
                                   VerticalAlignment="Top"
                                   TextWrapping="Wrap"
                                   Style="{StaticResource PhoneTextNormalStyle}"
                                   Text="{Binding}" />
                        <Controls:LoadingItemRetryButton Foreground="{StaticResource PhoneAccentBrush}"
                                                         FontFamily="{StaticResource PhoneFontFamilySemiLight}"
                                                         FontSize="{StaticResource PhoneFontSizeLarge}"
                                                         Grid.Row="1"
                                                         Content="try again">
                            <Controls:LoadingItemRetryButton.Template>
                                <ControlTemplate TargetType="Button">
                                    <ContentPresenter Margin="12,0,12,0"
                                                      Content="{TemplateBinding Content}" />
                                </ControlTemplate>
                            </Controls:LoadingItemRetryButton.Template>
                        </Controls:LoadingItemRetryButton>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="TimeoutContent"
                Value="It's taking a while to load this information. Perhaps you should try again later." />
        <Setter Property="TimeoutContentTemplate"
                Value="{StaticResource LoadingTextSmallDataTemplate}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:LoadingContentControl">
                    <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="Covering">
                                <VisualState x:Name="Covered">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="Cover">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation BeginTime="0"
                                                         Duration="0:0:0.5"
                                                         To="1"
                                                         Storyboard.TargetName="Cover"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Uncovered">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="Cover">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.5">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation BeginTime="0"
                                                         Duration="0:0:0.5"
                                                         To="0"
                                                         Storyboard.TargetName="Cover"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid CacheMode="BitmapCache"
                              Visibility="Collapsed"
                              x:Name="Content" />
                        <Grid x:Name="Cover"
                              Background="{TemplateBinding Background}"
                              Margin="{TemplateBinding CoverOffset}">
                            <ContentPresenter Content="{TemplateBinding Cover}"
                                              ContentTemplate="{TemplateBinding CoverTemplate}" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Controls:BaseCoverContentControl">
        <Setter Property="Background"
                Value="{StaticResource PhoneBackgroundBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:BaseCoverContentControl">
                    <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="Covering">
                                <VisualState x:Name="Covered">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="Content">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.5">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="Cover">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation BeginTime="0"
                                                         Duration="0:0:0.5"
                                                         To="1"
                                                         Storyboard.TargetName="Cover"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Uncovered">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="Content">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="Cover">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.5">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation BeginTime="0"
                                                         Duration="0:0:0.5"
                                                         To="0"
                                                         Storyboard.TargetName="Cover"
                                                         Storyboard.TargetProperty="Opacity" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid CacheMode="BitmapCache"
                              Visibility="Collapsed"
                              x:Name="Content">
                            <ContentPresenter Content="{TemplateBinding Content}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}" />
                        </Grid>
                        <Grid x:Name="Cover"
                              Background="{TemplateBinding Background}"
                              Margin="{TemplateBinding CoverOffset}">
                            <ContentPresenter Content="{TemplateBinding Cover}"
                                              ContentTemplate="{TemplateBinding CoverTemplate}" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>